:: 【一、安装私有docker仓库】
:: 【删除容器】。-f 代表 force
:: docker rm [OPTIONS] CONTAINER [CONTAINER...]
:: docker rm -f registry

:: 【下载安装容器】下载并安装私有仓库 registry
docker run -d -p 5000:5000 --name registry --restart always registry:latest

:: 【二、使用私有docker仓库】
:: 【拉取镜像】pull个镜像待用
docker pull nginx

:: 【标记本地镜像】，将其归入某一仓库。字必须跟你注册账号一样。
:: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
docker tag nginx localhost:5000/nginx
:: docker tag nginx localhost:5000/lishuoboy/nginx

:: 【上传镜像】将本地的镜像上传到镜像私有仓库。
:: docker push [OPTIONS] NAME[:TAG]
docker push localhost:5000/nginx
:: docker push localhost:5000/lishuoboy/nginx

:: 【查看仓库镜像】查看私有仓库内的镜像。全部registry API 见官网 https://docs.docker.com/registry/spec/api/。附图 11.
http://localhost:5000/v2/_catalog
:: http://localhost:5000/v2/{image_name}/tags/list
http://localhost:5000/v2/nginx/tags/list


:: pull＆run 试试(先删除本地镜像)
docker run -d -p80:80 --name nginx localhost:5000/nginx
:: docker run -d -p80:80 --name nginx localhost:5000/lishuoboy/nginx

:: 访问试试
http://localhost:80

::【三、删除私有仓库镜像】
:: 【查看镜像sha256】
curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -XGET http://localhost:5000/v2/nginx/manifests/latest
:: 【删除】注意默认禁止删除。修改参考 https://chen2ha.blog.csdn.net/article/details/123571707
curl -I -X DELETE http://localhost:5000/v2/nginx/manifests/sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
:: 【查看】再次查看仓库tag。tag消失，库还在。
http://localhost:5000/v2/nginx/tags/list
:: 清理垃圾
docker exec -it registry sh -c ' registry garbage-collect /etc/docker/registry/config.yml'